package io.bsly.modules.platform.controller;

import io.bsly.common.utils.R;
import io.bsly.modules.app.annotation.JwtIgnore;
import io.bsly.modules.app.service.localmaster.DyOfficalOrderService;
import io.bsly.modules.platform.api.douDianApi.DouDianApi;
import io.bsly.modules.platform.api.douDianApi.DouDianConfigVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@Slf4j
@RestController
@RequestMapping("api/sdk")
public class DouDianApiController {
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    DouDianConfigVo douDianConfig;
    @Autowired
    DyOfficalOrderService dyOfficalOrderService;

    @Autowired
    DouDianApi douDianApi;

    @JwtIgnore
    @GetMapping("orderList")
    public R orderList(Long page ,Long size ,String startTime, String endTime){
        return douDianApi.doudianOrderList(page, size, startTime, endTime);
    }

    @JwtIgnore
    @GetMapping("token")
    public R getToken(){
            String token = douDianApi.accessToken().getAccessToken();
            return  R.ok(token);
    }

    @JwtIgnore
    @GetMapping("refreshToken")
    public R refresh_token() throws IOException{
        douDianApi.refreshToken();
        return  R.ok();
    }


}
